<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="js/vue.js"></script>
  <style>
    .active {
      color: red;
    }
  </style>
</head>
<body>
  <div id="app">
    <!-- v-bind动态绑定属性 -->
    <img v-bind:src="imgUrl" alt="" srcset="">
    <!-- 简写，语法糖 -->
    <a :href="aHref">Baidu</a>

  </div>


  <!-- 动态绑定class -->
  <div id="app2">
    <!-- 方法一, 直接传递字符串 -->
    <h2 :class="show">{{message}}</h2>

    <!-- 方法二, 对象语法，即传递一些键值对，推荐 -->
    <h2 v-bind:class="{active: isActive, line: isLine}">{{message}}</h2>
    <button @click="btnClick">button</button>

    <!-- 方法三, 数组语法，推荐 -->

  </div>

  <script>
    let app = new Vue({
      el: "#app",
      data: {
        imgUrl: "https://i0.hdslb.com/bfs/face/d62343652a90d726e383da8642d914326cfa8bfd.jpg@160w_160h_1c.jpg",
        aHref: "http://www.baidu.com"
      }
    })

    let app2 = new Vue({
      el: "#app2",
      data: {
        message: "Hello Vue!",
        show: "active",
        isActive: true,
        isLine: false
      },
      methods: {
        btnClick: function () {
          this.isActive = !this.isActive;
        }
      }
    })
  </script>
</body>
</html>